Question about QUERY_STRING redirects with mod_rewrite

Question about QUERY_STRING redirects with mod_rewrite

am 09.02.2010 20:00:09 von Tiago Marques

--0016e65b61cc05822f047f2f88b2
Content-Type: text/plain; charset=UTF-8

Hi,

I'm trying to do 301 redirects from a website which used queries extensively
but doesn't use any now. I found this piece of code but it doesn't seem to
work.

RewriteEngine on

RewriteCond %{QUERY_STRING} ^id=13$

RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]


All the examples I found are very similar to this one but I can't get any of
them to work, it simply keeps the ?id=13 part and doesn't rewrite the url.
Am I doing anything wrong or has something changed from one mod_rewrite
revision to another?

Best regards,
Tiago Marques

--0016e65b61cc05822f047f2f88b2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi,

I'm trying to do 301 redirects from a=
website which used queries extensively but doesn't use any now. I foun=
d this piece of code but it doesn't seem to work.



px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-=
left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex=
; ">

RewriteEngine on 
=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.=
8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-=
left-style: solid; padding-left: 1ex; ">

RewriteCond %{QUERY_STRING} ^id=3D13$
l_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; m=
argin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204,=
204); border-left-style: solid; padding-left: 1ex; ">

RewriteRule ^/page.php$ http=
://www.example.com/newname.htm
? [L,R=3D301]

=
All the examples I found are very similar to this one but I can't =
get any of them to work, it simply keeps the ?id=3D13 part and doesn't =
rewrite the url.


Am I doing anything wrong or has something changed from one mod_rewrit=
e revision to another?

Best regards,
Tia=
go Marques


--0016e65b61cc05822f047f2f88b2--

Re: Question about QUERY_STRING redirects with

am 09.02.2010 20:10:13 von Eric Covener

On Tue, Feb 9, 2010 at 2:00 PM, Tiago Marques wrote:
> Hi,
> I'm trying to do 301 redirects from a website which used queries extensively
> but doesn't use any now. I found this piece of code but it doesn't seem to
> work.
>>
>> RewriteEngine on
>>
>> RewriteCond %{QUERY_STRING} ^id=13$
>>
>> RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
>
> All the examples I found are very similar to this one but I can't get any of
> them to work, it simply keeps the ?id=13 part and doesn't rewrite the url.
> Am I doing anything wrong or has something changed from one mod_rewrite
> revision to another?

If it's not doing anything, maybe you put them in the wrong VirtualHost?

If you put it in .htaccess, the RewriteRule will never match due to
only matching a leading slash -- those are never present in
per-directory context. You'd also need to make sure AllowOverride was
set for that Directory.


--
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Question about QUERY_STRING redirects with

am 09.02.2010 20:20:16 von Tiago Marques

--001636416dfbf99d11047f2fcf56
Content-Type: text/plain; charset=UTF-8

On Tue, Feb 9, 2010 at 7:10 PM, Eric Covener wrote:

> On Tue, Feb 9, 2010 at 2:00 PM, Tiago Marques wrote:
> > Hi,
> > I'm trying to do 301 redirects from a website which used queries
> extensively
> > but doesn't use any now. I found this piece of code but it doesn't seem
> to
> > work.
> >>
> >> RewriteEngine on
> >>
> >> RewriteCond %{QUERY_STRING} ^id=13$
> >>
> >> RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
> >
> > All the examples I found are very similar to this one but I can't get any
> of
> > them to work, it simply keeps the ?id=13 part and doesn't rewrite the
> url.
> > Am I doing anything wrong or has something changed from one mod_rewrite
> > revision to another?
>
> If it's not doing anything, maybe you put them in the wrong VirtualHost?
>
> If you put it in .htaccess, the RewriteRule will never match due to
> only matching a leading slash -- those are never present in
> per-directory context. You'd also need to make sure AllowOverride was
> set for that Directory.
>
>
It was in the .htaccess. You were absolutely right, with the leading slash
removed it works great. I'm not using "AllowOverride" though, will I have
any problem because of it?
Thank you for helping out.

Best regards


>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--001636416dfbf99d11047f2fcf56
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Feb 9, 2010 at 7:10 PM, Eric Covener an dir=3D"ltr"><covener@gmail.com a>> wrote:
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

On Tue, Feb 9, 2010 at 2:00 PM, Tiago Mar=
ques <> w=
rote:

> Hi,

> I'm trying to do 301 redirects from a website which used queries e=
xtensively

> but doesn't use any now. I found this piece of code but it doesn&#=
39;t seem to

> work.

>>

>> RewriteEngine on

>>

>> RewriteCond %{QUERY_STRING} ^id=3D13$

>>

>> RewriteRule ^/page.php$
htm" target=3D"_blank">http://www.example.com/newname.htm? [L,R=3D301]<=
br>
>

> All the examples I found are very similar to this one but I can't =
get any of

> them to work, it simply keeps the ?id=3D13 part and doesn't rewrit=
e the url.

> Am I doing anything wrong or has something changed from one mod_rewrit=
e

> revision to another?



If it's not doing anything, maybe you put them in the wrong=
VirtualHost?



If you put it in .htaccess, the RewriteRule will never match due to

only matching a leading slash -- those are never present in

per-directory context.  You'd also need to make sure AllowOverride=
was

set for that Directory.



It was in the .htaccess. You were abso=
lutely right, with the leading slash removed it works great. I'm not us=
ing "AllowOverride" though, will I have any problem because of it=
?


Thank you for helping out.

Best regards
=
 
ex;border-left:1px #ccc solid;padding-left:1ex;">


--

Eric Covener





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

  "   from the digest: scribe@httpd.apache.org">users-digest-unsubscribe@httpd.apac he.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--001636416dfbf99d11047f2fcf56--